package org.red_cross_service.config;

import jakarta.validation.constraints.NotNull;
import org.red_cross_service.interceptor.AppInterceptor;
import jakarta.annotation.Resource;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * Web应用配置
 */
@Configuration
public class ApplicationConfig implements WebMvcConfigurer {

    @Resource
    AppInterceptor appInterceptor;

    @Value("${files.upload.path}")
    private String fileUploadPath;

    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        registry.addResourceHandler("/static/uploadFile/**").addResourceLocations("file:" + fileUploadPath);
    }

//    @Override
//    public void addInterceptors(@NotNull InterceptorRegistry registry) {
//        registry.addInterceptor(appInterceptor).addPathPatterns("/**").excludePathPatterns("/static/uploadFile/**");
//        ;
//    }

}
